package com.qianli.user.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午10:00
 */
public enum MarriageEnum {
    NOT_MARRIED(0, "未婚"),
    MARRIED_AND_PROCREATED(1, "已婚已育"),
    MARRIED_AND_NOT_PROCREATED(2, "已婚未育"),
    OTHER(3, "其他");

    private Integer type;
    private String desc;

    MarriageEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public MarriageEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public MarriageEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (MarriageEnum enumObj : MarriageEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static MarriageEnum getEnumByType(Integer type) {
        MarriageEnum userMarriageEnum = null;
        for (MarriageEnum enumObj : MarriageEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userMarriageEnum = enumObj;
                break;
            }
        }
        return userMarriageEnum;
    }
    
    public static MarriageEnum getEnumByDesc(String desc) {
        MarriageEnum userMarriageEnum = null;
        for (MarriageEnum enumObj : MarriageEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userMarriageEnum = enumObj;
                break;
            }
        }
        return userMarriageEnum;
    }
}
